#include "addfriendbox.h"
#include "ui_addfriendbox.h"

AddFriendBox::AddFriendBox(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AddFriendBox)
{
    ui->setupUi(this);
    isvalid=false;
}

AddFriendBox::~AddFriendBox()
{
    delete ui;
}

void AddFriendBox::setFriendName(const QString& useroc,const QString& friendoc,const QString& friendname)
{
    ui->label_avatar->setPixmap("./User/"+useroc+"/Cache/"+friendoc+".png");
    ui->label_friendname->setText(friendname);
    this->friendname=friendname;
}

void AddFriendBox::setExists(bool flag)
{
    if(flag)
    {
        ui->btn_addfriend->setCursor(Qt::ForbiddenCursor);
        isvalid=false;
    }
    else
    {
        ui->btn_addfriend->setCursor(Qt::PointingHandCursor);
        isvalid=true;
    }
}

QSize AddFriendBox::getSize()
{
    return this->sizeHint();
}

void AddFriendBox::on_btn_addfriend_clicked()
{

    if(isvalid)
        emit btn_clicked(friendname);
    setExists(true);
}
